package com.example.dirviesystem.repository;

import com.example.dirviesystem.entity.Question;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

public interface StudentQuestionRepository extends JpaRepository<Question, Long> {

    List<Question> findBySubject(String subject);

    // 固定100条随机题目
    @Query(value = "SELECT TOP 100 * FROM question WHERE subject = :subject ORDER BY NEWID()", nativeQuery = true)
    List<Question> findSimulateQuestions(@Param("subject") String subject);


}
